package com.t.bricks.bussiness.db.mapper.flowwork;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import com.t.bricks.bussiness.db.entity.flowwork.FlowWorkNode;
import com.t.bricks.bussiness.db.entity.flowwork.base.FlowWorkNodeBase;

@Mapper
public interface FlowWorkNodeMapper {
	
	/**
	 * 创建流程实例下的节点
	 * @Param sWorkId
	 * @Param sDefineSign
	 * @Param sCreator
	 * @return int
	 */
	int createNode(
		@Param("sWorkId") String sWorkId,
		@Param("sDefineSign") String sDefineSign,
		@Param("sCreator") String sCreator
	);

	/**
	 * 删除流程实例下的节点
	 * @Param sWorkId
	 * @return int
	 */
	int delBysWorkId(@Param("sWorkId") String sWorkId);

	/**
	 * 修改节点
	 * 注意:当对象的属性值为null时不更新字段
	 * @Param flowWorkNodeBase
	 * @return int
	 */
	int editNode(FlowWorkNodeBase flowWorkNodeBase);

	/**
	 * 查找当前节点
	 * @Param sWorkId
	 * @return FlowWorkNode
	 */
	FlowWorkNode findCurrentNode(@Param("sWorkId") String sWorkId);
	
	/**
	 * 修改指定节点内容描述
	 * @param uId
	 * @param iVersion
	 * @param sDescription
	 * @return
	 */
	int editDescription(
		@Param("uId") String uId,
		@Param("iVersion") Integer iVersion,
		@Param("sDescription") String sDescription
	);

	/**
	 * 关闭提醒
	 * @param uId
	 * @param iVersion
	 * @param sUserId
	 * @return
	 */
	int stopReminder(
		@Param("uId") String uId,
		@Param("iVersion") Integer iVersion,
		@Param("sUserId") String sUserId
	);
	
	/**
	 * 审批节点
	 * @param flowWorkNode
	 * @return
	 */
	int auditing(FlowWorkNode flowWorkNode);
	
	/**
	 * 结束节点
	 * @param flowWorkNode
	 * @return
	 */
	int over(FlowWorkNode flowWorkNode);

	/**
	 * 查询实例下的所有节点(只有相关人员才能看到)
	 * @param sWorkId 所属实例编号
	 * @param sUserId 相关人员
	 * @return
	 */
	FlowWorkNode findByWork(
		@Param("sWorkId") String sWorkId,
		@Param("sUserId") String sUserId
	);
	
	/**
	 * 查找发起者节点
	 * @param sWorkId
	 * @return
	 */
	FlowWorkNode findByType2(@Param("sWorkId") String sWorkId);
	
	/**
	 * 查找所有审核完毕待执行任务的节点
	 * @return
	 */
	List<FlowWorkNode> findByType3();
	
	/**
	 * 查找所有审核完毕待执行任务的节点数量
	 * @return
	 */
	int findCountByType3();
	
	/**
	 * 更新任务执行信息
	 * @param flowWorkNode
	 * @return
	 */
	int editApiResult(FlowWorkNode flowWorkNode);

}
